import { Input,Upload, message, Button, Icon } from 'antd';
import { connect } from "dva";
import {useState,useEffect} from 'react';
import styles from './addUser.css';

// const fileList = []
// const props1 = {
//   action: '',
//   listType: 'picture',
//   defaultFileList: [...fileList],
// };

function addUser(props) {
	let value1 ="";
	let value2 ="";
	let value3 ="";
	
	useEffect(()=>{
		console.log(props)
	})
	
	
	
  return (
    <div className={styles.normal}>
      <h1>分类商品添加</h1>
	  <Input placeholder="商品名称" type="text" ref={(val) =>value1 = val}/>
	  <Input placeholder="商品描述" type="text" ref={(val) =>value2 = val}/>
	  <Input placeholder="商品图片" type="text" ref={(val) =>value3 = val}/>
	  {/*<Upload {...props1}>
	        <Button className={styles.upload}>
	          <Icon type="upload" ref='upload'/> 上传头像
	        </Button>
	     </Upload>*/}
		<Button type="primary" className={styles.add} onClick={()=>
		props.dispatch({
			type:'info/addProductCategoriesInfo',
			payload:{
				name:value1.state.value,
				descriptions:value2.state.value,
				coverImg:value3.state.value
			}
		}).then(()=>{
			console.log(props.mess)
			if(props.mess){
				message.success('添加成功~')
				props.history.push('/home/fenlei')
			}
			})
	}>添加</Button>
    </div>
  );
}
export default connect(state=>state.info)(addUser)